import axios from 'axios';
import { API_VERSION, API_NEW_VERSION, ALL_SERVICE_API } from '../api';

var qs = require('qs');
// 获取列表展示数据
export const getItemNames = params => {
  return axios.get(API_VERSION + 'stm_item_names', {params: params});
};

// 获取列表展示数据
export const getItemNamesNew = params => {
  return axios.get(ALL_SERVICE_API + '/item-names', {params: params});
};

/**
 * 获取列表展示数据
 * 不分页
 * @param params
 * @returns {AxiosPromise}
 */
export const getItemNamesNoPage = params => {
  return axios.get(API_NEW_VERSION + 'stm_item_names', {params: params});
};

// 获取单个货物品名信息stm_item_name/cargo
export const getItemNameById = params => {
  return axios.get(API_VERSION + 'stm_item_name/cargo/' + params.id.trim(), {params: params});
};

// 保存
export const saveItemName = params => {
  return axios.post(ALL_SERVICE_API + '/item-names', params);
};

// 更改状态/stm_item_name_modify_stauts
export const modifyStatus = (id, status) => {
  return axios.post(ALL_SERVICE_API + '/stm_item_name_modify_stauts', qs.stringify({
    id: id,
    status: status
  }));
};

// 单个删除stm_item_name
export const deleteItemName = id => {
  return axios.delete(ALL_SERVICE_API + '/item-names/' + id);
};
